package hk.edu.uic.hejing.entity;

import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.enums.IdType;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.activerecord.Model;
import hk.edu.uic.hejing.security.PassEncrypt;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;

/**
 * <p>
 * 
 * </p>
 *
 * @author hejing
 * @since 2017-05-30
 */
@SuppressWarnings("serial")
public class Teacher extends Model<Teacher> {

    private static final long serialVersionUID = 1L;

	@TableId(value="id",type = IdType.AUTO)
	private Integer id;
	@TableField("name")
	private String name;
	@TableField("pass")
	private String pass;
	@TableField("email")
	private String email;

	public Teacher(){}

	public Teacher(String pass, String email) throws UnsupportedEncodingException, NoSuchAlgorithmException {
		this.email = email;
		this.pass =  PassEncrypt.EncoderByMd5(pass);

	}

	public Teacher(String name, String pass, String email) throws NoSuchAlgorithmException, UnsupportedEncodingException {
		this.name = name;
		this.pass =  PassEncrypt.EncoderByMd5(pass);
		this.email = email;
	}



	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPass() {
		return pass;
	}

	public void setPass(String pass) throws NoSuchAlgorithmException, UnsupportedEncodingException {
		this.pass = PassEncrypt.EncoderByMd5(pass);
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Override
	public String toString() {
		return "Teacher{" +
				"id=" + id +
				", name='" + name + '\'' +
				", pass='" + pass + '\'' +
				", email='" + email + '\'' +
				'}';
	}

	@Override
	protected Serializable pkVal() {
		return this.id;
	}

}
